#pragma once

#include <linux/mutex_types.h>
#include <linux/lockdep.h>

#define __mutex_init(mutex, name, key)         \
    do                                         \
    {                                          \
        rt_mutex_base_init(&((mutex)->rtmutex)); \
        __mutex_rt_init(&((mutex)->rtmutex), name, key);   \
    } while (0)

/**
 * mutex_init - initialize the mutex
 * @mutex: the mutex to be initialized
 *
 * Initialize the mutex to unlocked state.
 *
 * It is not allowed to initialize an already locked mutex.
 */
#define mutex_init(mutex)                      \
    do                                         \
    {                                          \
        static struct lock_class_key __key;    \
                                               \
        __mutex_init((mutex), #mutex, &__key); \
    } while (0)
